package com.icss.ah.productForShow.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ProductForShowService {
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	
	private final Logger errlog = Logger.getLogger("E");
	private final Logger infolog = Logger.getLogger("I");
	
	
	/**
	 * 查询店铺商品销售信息
	 * @param map
	 * @return
	 */
	public List<Map> queryProductForShowList(Map map){
		List<Map> list=new ArrayList<Map>();
		try {
			list=sqlSessionTemplate.selectList("ProductForShowBean.queryProductForShowList",map);
            infolog.info("ProductForShowService|queryProductForShowList|list="+list);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("ProductForShowService|queryProductForShowList",e);
		}						
		return list;
	}
	
	/**
	 * 查询店铺商品销售信息总记录数
	 * @param map
	 * @return
	 */
	public long queryProductForShowCount(Map map){
		long count=0l;
		try {
			count=(Long)sqlSessionTemplate.selectOne("ProductForShowBean.queryProductForShowCount", map);
			infolog.info("ProductForShowService|queryProductForShowCount|count="+count);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("ProductForShowService|queryProductForShowCount",e);
		}				
		return count;
	}
}
